package com.yanfan.zutai.mapper;


import com.yanfan.zutai.domain.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public interface BCommonMapper {

    /**
     * 查询报警参数
     *
     * @param dictType 字典表类别dictType
     * @return
     */
    @Select("SELECT dict_value from sys_dict_data where dict_label =#{dictType}")
    Double getdictValue(String dictType);

    /**
     * 查询温度报警设备数
     *
     * @param temperatureMin 温度报警最小值、温度报警最大值
     * @return
     */
    //@Select("SELECT * from b_device_manager where (temperature < #{temperatureMin} or temperature >#{temperatureMax})")
    //@Param("gameTypeId")Long gameTypeId, @Param("goodsTypeId") Long goodsTypeId
    List<BDeviceManager> getTemperatureNumber(@Param("temperatureMin") Double temperatureMin, @Param("temperatureMax") Double temperatureMax, @Param("dept") String dept);

    /**
     * 查询电压报警设备数
     *
     * @param voltageMin 电压报警最小值、电压报警最大值
     * @return
     */
    @Select("SELECT * from b_device_manager where (voltage < #{voltageMin} or voltage >#{voltageMax}) and dept_Id_strs like concat('%', #{dept}, '%')")
    List<BDeviceManager> getVoltageNumber(@Param("voltageMin") Double voltageMin, @Param("voltageMax") Double voltageMax, @Param("dept") String dept);

    /**
     * 查询压强报警设备数
     *
     * @param pressureMin 压强报警最小值、压强报警最大值
     * @return
     */
    @Select("SELECT * from b_device_manager where (pressure < #{pressureMin} or pressure >#{pressureMax}) and dept_Id_strs like concat('%', #{dept}, '%')")
    List<BDeviceManager> getPressureNumber(@Param("pressureMin") Double pressureMin, @Param("pressureMax") Double pressureMax, @Param("dept") String dept);

    /**
     * 查询设备总数
     *
     * @return
     */
    @Select("SELECT * from b_device_manager where  dept_Id_strs like concat('%', #{dept}, '%') ")
    List<BDeviceManager> getInstalledNumber(@Param("dept") String dept);

    /**
     * 查询未安装设备数
     *
     * @return
     */
    @Select("SELECT * from b_device_manager where installation_time is null and dept_Id_strs like concat('%', #{dept}, '%')")
    List<BDeviceManager> getUnInstalledNumber(@Param("dept") String dept);

    /**
     * 查询未激活数
     *
     * @return
     */
    @Select("SELECT * from b_device_manager where is_activation =0 and dept_Id_strs like concat('%', #{dept}, '%')")
    List<BDeviceManager> getNotActiveNumber(@Param("dept") String dept);

    /**
     * 查询激活数
     *
     * @return
     */
    @Select("SELECT * from b_device_manager where is_activation =1 and dept_Id_strs like concat('%', #{dept}, '%')")
    List<BDeviceManager> getActiveNumber(@Param("dept") String dept);

    /**
     * 查询工单编号
     *
     * @return
     */
    @Select("select count(*) from b_work_order where  TO_DAYS(create_time)= TO_DAYS(NOW())  and type=#{workType} and dept_Id_strs like concat('%', #{dept}, '%')")
    Integer getWorkNumber(@Param("workType") String workType, @Param("dept") String dept);

    List<BDeviceZt> selectBDeviceZtList(BDeviceZt bDeviceZt);

    List<BDeviceZt> selectBDeviceZtListUser(@Param("DeptId") Long DeptId, @Param("pageName") String pageName);

    BDeviceZt getZtData(@Param("deviceMac") String deviceMac, @Param("guid") String guid);

    List<BDeviceZtBind> selectBDeviceZtBindList(BDeviceZtBind bDeviceZtBind);

    List<BDeviceModel> selectBDeviceModelList(BDeviceModel bDeviceModel);

    List<SysUpload> selectSysUploadList(SysUpload sysUpload);

    void insertBDeviceZtBind(BDeviceZtBind bDeviceZtBind);

    int insertBDeviceZt(BDeviceZt bDeviceZt);

    void updateBDeviceZt(BDeviceZt deviceZt);

    int deleteBDeviceZtByIds(Long[] ids);

    List<BDeviceRealData> selectBDeviceRealDataList(BDeviceRealData bDeviceRealData);

    List<BDeviceParameter> selectBDeviceParameterList(BDeviceParameter bDeviceParam);

    public int insertSysUpload(SysUpload sysUpload);

    /**
     * 修改上传信息
     *
     * @param sysUpload 上传信息
     * @return 结果
     */
    public int updateSysUpload(SysUpload sysUpload);

    public int deleteSysUploadByIds(Long[] ids);

    SysUpload selectSysUploadById(Long id);

    BDeviceZt selectBDeviceZtById(Long id);

    int deleteBDeviceZtBindByIds(Long[] ids);

    List<BDeviceRealData> selectDeviceAndModels(@Param("ztGuid") String ztGuid, @Param("modelName") String modelName);

    List<CopDTO> calcCop(@Param("beginDate") String beginDate, @Param("endDate") String endDate);

    int insertCop(CopDTO copDTO);

    List<CopDTO> selectCop(@Param("beginDate") String beginDate, @Param("endDate") String endDate);

    void deleteFunctionLog(@Param("yesterday") String yesterday);

    void deleteDeviceLog(@Param("yesterday") String yesterday);
}
